package com.fzj.example.socket.tcp.nonblock.bio;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * ClassName: HandlerExecutorPool
 * date: 2019/11/18 11:00
 * Description: TODO
 *
 * @author fanzj@bonree.com
 * @since JDK 1.8
 */
public class HandlerExecutorPool {

    private ExecutorService executorService;

    public HandlerExecutorPool(int poolSize,int queueSize){
        executorService=new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(),poolSize,1000, TimeUnit.SECONDS,new ArrayBlockingQueue<>(queueSize));
    }

    public void execute(Runnable runnable){
        this.executorService.execute(runnable);
    }

}
